/**
 * 队列性质的ui管理器
 */
import LayerManager from "./LayerManager"
import LayerInterface from "./LayerInterface";
export default class QueueLayerManager extends LayerManager {

    //添加layer
    pushView(view: LayerInterface) {
        this.list.push(view);
        // console.log(' QueueLayerManager pushView count ', this.list.length)

        if (this.list.length == 1) {
            this.show(view);
        }
    }

    show(view: LayerInterface) {
        // let node: Laya.View = layerInfo.getLayer()
        view.setOrder(this.zOrder);
        this.root.addChild(view.getNode())
    }
    // 移除layer
    popView(view: any): boolean {
        if (!view) {
            if (this.list.length > 0) {
                let layerInfo = this.list.shift();
                layerInfo.exit();
                if (this.list.length > 0) {
                    this.show(this.list[0]);
                }
                return true;
            } else {
                return false;
            }

        } else {
            return this.removeView(view);
        }

    }


}
